const https = require('https')
const fs = require('fs')
const path = require('path')
// console.log(path.resolve(__dirname, '../privatekey.pem'));
const pk = fs.readFileSync(path.resolve(__dirname, '../privatekey.pem'))
const pc = fs.readFileSync(path.resolve(__dirname, '../certificate.pem'))
console.log(pk, pc);
const opts = {
  key: pk,
  cert: pc
}
const server = https.createServer(opts, function (req, res) {
  console.log(req, res);
  if (req.url !== "/favicon.ico") {
    res.setHeader('Content-Type', 'text/html');
    res.write('<html><head><meta charset="utf-8"/></head>');
    res.write('<body><h1>你好</h1></body>')
    res.end()
  }

}).listen(443, 'localhost', function () {
  console.log('http server start', server.address());
})